<template>
  <div>
    <div @keyup.enter="getData()">
      <el-form class="query-table-form" :inline="true">
        <el-form-item>
          <el-input v-model="params.customer_name" placeholder="项目名称查询" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-input
            v-model="params.corp_name"
            placeholder="负责人查询"
            :clearable="true"
          ></el-input>
        </el-form-item>
        <el-form-item>
          <select-address
            v-model="params.address_code"
            clearable
            placeholder="地址查询"
            :auto-top="true"
            @change="getData()"
          ></select-address>
        </el-form-item>
        <el-form-item>
          <el-button @click="getData()">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="exportExcel('审批推荐')" :loading="exportLoading">导出</el-button>
        </el-form-item>
      </el-form>
    </div>
    <c-table
      border
      v-loading="loading"
      :stripe="false"
      :columns="tableColumns"
      :data="tableData"
      height="76vh"
    ></c-table>

    <div class="query-pagination">
      <div></div>
      <el-pagination
        layout="total, prev, pager, next, jumper"
        :current-page.sync="params.index"
        :page-size="params.size"
        :total="totalCount"
        @current-change="getData"
      ></el-pagination>
    </div>

    <el-dialog
      :visible.sync="attachVisible"
      :close-on-click-modal="false"
      append-to-body
      top="30px"
      width="1100px"
    >
      <el-tabs>
        <el-tab-pane label="数字档案卡">
          <industry-credit :query-id="whiteId" :view-mode="true"></industry-credit>
        </el-tab-pane>
      </el-tabs>
    </el-dialog>

    <el-dialog
      :visible.sync="approvalVisble"
      :close-on-click-modal="false"
      append-to-body
      title="审批推荐"
      top="30px"
      width="1100px"
    >
      <approval-table
        :info-data="infoData"
        :view-mode="viewMode"
        @success="handleEditSuccess"
      ></approval-table>
    </el-dialog>
  </div>
</template>
<script>
import { enumProjectType } from '@/gov/plugins/enum'
import taskTableMixin from '@/credit/mixin/task/taskTable'
import SelectAddress from '@/components/select/SelectAddress'
import IndustryCredit from '@/gov/views/files/IndustryCredit'
import ApprovalTable from '@/gov/views/index/task/ApprovalTable'
export default {
  components: {
    SelectAddress,
    IndustryCredit,
    ApprovalTable,
  },
  mixins: [taskTableMixin],
  props: {},
  data() {
    return {
      enumProjectType,
      loading: false,
      order: { N1archive_complete_time: 'desc' },
      params: {
        index: 1,
        size: 10,
        'submit_type.eq': 1,
      },
      tableData: [],
      tableColumns: [
        { attrs: { label: '主体名称', prop: 'customer_name', align: 'center' } },
        { attrs: { label: '地址', prop: 'address', align: 'center' } },
        { attrs: { label: '负责人', prop: 'corp_name', align: 'center' } },
        { attrs: { label: '联系电话', prop: 'mobile_no', align: 'center' } },
        { attrs: { label: '所属产业包', prop: 'project_type_name', align: 'center' } },
        // { attrs: { label: '申请表', prop: 'statusLabel', align: 'center' } },
        {
          attrs: { label: '操作', align: 'center' },
          operations: [
            {
              content: '审批推荐',
              icon: 'fa fa-edit',
              event: this.handleApproval,
              ifRender: row => +row.task_status === 0,
            },
            {
              content: '审批推荐表',
              icon: 'fa fa-file-text',
              event: this.handleApproval,
              ifRender: row => +row.task_status === 1,
            },
            {
              content: '查看',
              icon: 'fa fa-search',
              event: this.handleView,
            },
          ],
        },
      ],
      tableName: 'project_white_list_task',
      infoData: {},
      approvalVisble: false,
      attachVisible: false,
      whiteId: '',
      viewMode: false,
    }
  },
  computed: {},
  watch: {
    visible() {
      if (this.visible) {
        this.getData()
      }
    },
  },
  created() {
    this.params['orWhere.address_code.endlike'] = this.$utils.getAddressCode().replace(/0*$/g, '')
    this.params['orWhere.task_person.like'] = this.userId
    this.params['task_status.eq'] = this.status
    this.params['task_type.eq'] = this.type
  },
  mounted() {},
  methods: {
    handleView(row) {
      this.whiteId = row.project_white_list_id
      this.attachVisible = true
    },
    getParams() {
      return this.params
    },
    getTabData() {
      this.getData()
    },
    beforeClose() {
      this.$emit('update:visible', false)
    },

    handleApproval(row) {
      this.infoData = { ...row }
      this.viewMode = +row.task_status === 1
      this.approvalVisble = true
    },

    dataAdapter(item) {
      // item.statusLabel = +item.is_finished_form === 1 ? '已完成' : '未完成'
      return item
    },
    handleEditSuccess() {
      this.approvalVisble = false
      this.$store.dispatch('getMyTaskCount')
      this.$emit('success', true)
    },
  },
}
</script>
<style lang="scss" scoped></style>
